<script setup lang="ts">
import {publishNew} from "@/http/tree/treeHole";
import {ref} from "vue";
import router from "@/router";


const title=ref<string>('')
const content=ref<string>('')
function publish(){
    publishNew({title:title.value,content:content.value}).then(res=>{
        console.log(res)
        router.push('/tree')
    })
}

</script>

<template>
    <div class="whole">
        <div class="input">
            <van-cell-group inset style="margin: 0">
                <van-field
                    style="background-color: #ECE2F8"
                    v-model="title"
                    rows="1"
                    autosize
                    label="标题"
                    type="textarea"
                    placeholder="请输入标题"
                />
                <van-field
                    style="background-color: #ECE2F8"
                    v-model="content"
                    rows="10"
                    :autosize={minHeight:300}
                    label="正文"
                    type="textarea"
                    placeholder="请输入正文"
                />
            </van-cell-group>
        </div>
        <div class="publish" @click="publish">
            <van-icon name="smile-o" />
            发布
        </div>
    </div>
</template>

<style scoped lang="less">
.whole {
  width: 94%;
  margin: 0 auto;
.input {
    margin-top: 3vh;
}

    .publish {
        border-radius: 5px;
        padding: 8px;
        background-color: #CEAFF8;
        font-size: 20px;
        position: fixed;
        bottom: 10vh;
        right: 10%;
        color: #7246c5;

    }

}
</style>